<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; utf-8">
    <meta charset="UTF-8">
    <title>WebSocket</title>
</head>
<script src="socket.js"></script>
<body>

    socket is running

<script>
    Socket.connection({
        //
        ip:"127.0.0.1",
        port:1234,

        //建立连接回调
        open:function(){
            alert('已连接!');
            //发送登录指令给服务器
            Socket.send({
                action:'login',
                msg:'123'
            });

        },
        //建立连接回调
        close:function(){
            //发送登录指令给服务器
            alert('连接已关闭!');
        },
        //服务器返回数据的业务处理
        message:function(event){
            var data = JSON.parse(event.data);
            var action = data.action;
            if(action=='xxx1'){
                ///
            }
            if(action=='xxx2'){
                ///
            }
            if(action=='xxx3'){
                ///
            }
        }
    });
</script>
<br>
<br>
</body>
</html>